import React, { Component } from 'react'
import getGlobalContext from "../../../utils/getGlobalContext";

export default class LoginBox extends Component {
  state = {
    userName: '',
    password: ''
  }

  onLogin() {
    console.log('this.state:', this.state)
  }


  render() {

    return (
        <getGlobalContext.Consumer>
            {
                (value) => {
                    console.log('value:', value)
                    return <div>
                        <label>用户名</label>
                        <input type="text" value={this.state.userName} onChange={(event) => {
                            this.setState({
                                userName: event.target.value
                            })
                        }}/>
                        <br></br>
                        <label>密码</label>
                        <input type="text" value={this.state.password} onChange={(event) => {
                            this.setState({
                                password: event.target.value
                            })
                        }}/>
                        <br></br>
                        <button onClick={() => this.onLogin()}>登录</button>
                    </div>
                }
            }

        </getGlobalContext.Consumer>
    )
  }
}
